//
//  RowScoreTableViewCell.m
//  LotteryProject
//
//  Created by 阳光 on 17/7/10.
//  Copyright © 2017年 阳光. All rights reserved.
//

#import "RowScoreTableViewCell.h"

@interface RowScoreTableViewCell ()

@property(nonatomic,strong)UILabel *weekLabel;

@property(nonatomic,strong)UIButton *collectionBtn;

@property(nonatomic,strong)UIView *midLine;

@property(nonatomic,strong)UILabel *leftNameLabel;

@property(nonatomic,strong)UILabel *rightNameLabel;

@property(nonatomic,strong)UILabel *stateLabel;

@property(nonatomic,strong)UILabel *timeLabel;

@property(nonatomic,strong)UILabel *numberLabel;

@property(nonatomic,strong)UIImageView *arrowIcon;

@end

@implementation RowScoreTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        // ➡️Cell类型
        self.accessoryType=UITableViewCellAccessoryNone;

        self.arrowIcon.hidden=NO;

        self.weekLabel.font=FontNumber(18);

        self.timeLabel.font=FontNumber(16);

        self.numberLabel.font=FontNumber(16);

        self.leftNameLabel.font=FontNumber(16);

        self.rightNameLabel.font=FontNumber(16);

        self.timeLabel.font=FontNumber(16);

        self.midLine.hidden=NO;

        self.backgroundColor=WhiteColor;
    }
    return self;
}

// weekLabel
- (UILabel *)weekLabel
{
    if (!_weekLabel) {
        _weekLabel=[self getLabelWithText:@"004  世非预 10-07 23:30" font:FontNumber(18) textColor:DarkGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByCharWrapping numberOfLines:1];
        [self.contentView addSubview:_weekLabel];
        [_weekLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.mas_equalTo(kmargin);
            make.width.mas_equalTo(APPW-kmargin*2);
        }];
    }
    return _weekLabel;
}

-(UIButton *)collectionBtn
{
    if (!_collectionBtn) {
        _collectionBtn=[UIButton new];
        _collectionBtn.backgroundColor=MainColor;
        [self.contentView addSubview:_collectionBtn];
        [_collectionBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.weekLabel.mas_left);
            make.size.mas_equalTo(CGSizeMake(kmargin*3,kmargin*3));
            make.top.mas_equalTo(self.weekLabel.mas_bottom).offset(kmargin);
        }];
    }
    return _collectionBtn;
}

-(UIView *)midLine
{
    if (!_midLine) {
        _midLine=[UIView new];
        _midLine.backgroundColor=LightGreyColor;
        [self.contentView addSubview:_midLine];
        [_midLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.collectionBtn.mas_top).offset(5);
            make.bottom.mas_equalTo(self.collectionBtn.mas_bottom).offset(-5);
            make.width.mas_equalTo(1);
            make.left.mas_equalTo(self.collectionBtn.mas_right).offset(kmargin*2);
        }];
    }
    return _midLine;
}

- (UILabel *)leftNameLabel
{
    if (!_leftNameLabel) {
        _leftNameLabel=[self getLabelWithText:@"加纳" font:FontNumber(16) textColor:LightGreyColor textAlignment:1 lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_leftNameLabel];
        [_leftNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-APPW/2);
            make.width.mas_equalTo(APPW/4);
            make.centerY.mas_equalTo(self.collectionBtn.mas_centerY);
        }];
    }
    return _leftNameLabel;
}

- (UILabel *)stateLabel
{
    if (!_stateLabel) {
        UILabel *vsLabel=[self getLabelWithText:@"VS" font:FontNumber(16) textColor:LightGreyColor textAlignment:1 lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:vsLabel];
        [vsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.leftNameLabel.mas_right).offset(kmargin);
            make.centerY.mas_equalTo(0);
        }];

        _stateLabel=[self getLabelWithText:@"未开始" font:FontNumber(16) textColor:LightGreyColor textAlignment:1 lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_stateLabel];
        [_stateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(vsLabel.mas_bottom).offset(kmargin);
            make.left.mas_equalTo(vsLabel.mas_left).offset(-kmargin);
        }];
    }
    return _stateLabel;
}


- (UILabel *)rightNameLabel
{
    if (!_rightNameLabel) {
        _rightNameLabel=[self getLabelWithText:@"乌干达" font:FontNumber(16) textColor:LightGreyColor textAlignment:NSTextAlignmentLeft lineBreakMode:NSLineBreakByTruncatingTail numberOfLines:1];
        [self.contentView addSubview:_rightNameLabel];
        [_rightNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(self.stateLabel.mas_right).offset(kmargin);
            make.centerY.mas_equalTo(self.collectionBtn.mas_centerY);
        }];
    }
    return _rightNameLabel;
}


// arrowIcon
-(UIImageView *)arrowIcon
{
    if (!_arrowIcon) {
        _arrowIcon=[UIImageView new];
        [self.contentView addSubview:_arrowIcon];
        _arrowIcon.image=[UIImage imageNamed:@"next_arrow"];
        [_arrowIcon mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(-kmargin*2);
            make.centerY.mas_equalTo(self);
            make.size.mas_equalTo(CGSizeMake(kmargin*3/2,kmargin*2));
        }];
    }
    return _arrowIcon;
}

@end
